﻿#ifndef QQTSYSTEMINFO_H
#define QQTSYSTEMINFO_H

#include <QObject>
#include <qqthighgrade_global.h>
#include <qqtcore.h>
#include <QMap>

typedef struct tDiskInfo
{
    tDiskInfo() {}
    quint64 mSize; //B
    quint64 mAvalableSize; //B
} TDiskInfo;

typedef struct tDiskTable
{
    tDiskTable() {}
    quint64 mNum;
    QList<TDiskInfo> mList;
} TDiskTable;

typedef struct tMemInfo
{
    tMemInfo() {}
} TMemInfo;

typedef struct tMemTable
{
    tMemTable() {}
    quint64 mTotalSize;//B
    quint64 mAvalableSize;//B
    quint64 mNum;
    QList<TMemInfo> mList;
} TMemTable;

typedef struct tCPUInfo
{
    tCPUInfo() {}
    quint64 mCoreNum;
    quint64 mThreadNumPerCore;
    quint64 mRate;
} TCPUInfo;

typedef struct tCPUTable
{
    tCPUTable() {}
    quint64 mNum;
    QList<TCPUInfo> mList;
} TCPUTable;

#define MB (1024 * 1024)

//头文件包含一定得有，否则incomplate type
//头文件必须在h文件里，否则QScopedPointer判断ClassPrivate incomplate type
#ifdef __WIN__
#include "qqtsysteminfo_win.h"
#elif defined(__DARWIN__)
#include "qqtsysteminfo_mac.h"
#else
#include "qqtsysteminfo_linux.h"
#endif
class QQtSystemInfoPrivate;

class QQTHIGHGRADESHARED_EXPORT QQtSystemInfo : public QObject
{
    Q_OBJECT

public:
    explicit QQtSystemInfo ( QObject* parent = nullptr );

    bool getOSInfo ( );
    bool getCPUInfo ( TCPUTable& cpuInfo );
    bool getMEMInfo ( TMemTable& memInfo );
    bool getDiskInfo ( TDiskTable& diskInfo );

signals:

public slots:

private:
    Q_DECLARE_PRIVATE ( QQtSystemInfo )
    Q_DISABLE_COPY ( QQtSystemInfo )
    QScopedPointer<QQtSystemInfoPrivate> d_ptr;
};

#endif // QQTSYSTEMINFO_H
